import type { AddressItem, OrderDetail, OrderPre, Logistics } from '@/types/order'
import { request } from '@/utils/request'

// 获取药品订单预支付信息
export const getMedicalOrderPre = (params: { prescriptionId: string }) => {
  return request<OrderPre>('patient/medicine/order/pre', 'get', params)
}

// 获取收货地址列表
export const getAddressList = () => {
  return request<AddressItem[]>('patient/order/address', 'get')
}

// 生成药品订单
export const createMedicalOrder = (params: {
  id: string
  addressId: string
  couponId?: string
}) => {
  return request<{ id: string }>('/patient/medicine/order', 'post', params)
}

// 获取药品订单详情
export const getMedicalOrderDetail = (orderId: string) =>
  request<OrderDetail>(`/patient/medicine/order/detail/${orderId}`, 'GET')

// 获取物流信息
export const getMedicalOrderLogistics = (id: string) =>
  request<Logistics>(`/patient/order/${id}/logistics`, 'GET')
